/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package src.report.loan;

import src.report.saving.*;
import java.io.IOException;
import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JREmptyDataSource;
import net.sf.jasperreports.engine.JRException;
import src.report.AbstractBaseReportBean;
import src.report.ReportFilter;
import src.view.system.CompanyBean;

/**
 *
 * @author Yusup Jauhari Shandi <in.visi>
 */
public class RptRekapKreditBean extends AbstractBaseReportBean{
    private final String COMPILE_FILE_NAME = "loan/rptRekapKredit";
    @Override
    protected JRDataSource getJRDataSource() {
        return (new JREmptyDataSource());
    }

    @Override
    protected String getCompileFileName() {
        return  COMPILE_FILE_NAME;
    }
    
    public String execute(ReportFilter reportFilter) {
		try {
                   super.getReportParameters().put("p_start", reportFilter.getTransDate1());
                   super.getReportParameters().put("p_end", reportFilter.getTransDate2());


                  /*  StringBuilder where = new StringBuilder("");
                    if ((reportFilter.getTransDate1()!=null)&&(reportFilter.getTransDate2()!=null))
                        where.append(" and sh.trans_date between ").append(Utils.formatSqlDate(reportFilter.getTransDate1())).append(" and ")
                                .append(Utils.formatSqlDate(reportFilter.getTransDate2()));
                    if (reportFilter.getCif()!=null)
                        where.append(" and c.cif like '%").append(reportFilter.getCif()).append("'");

                /* if (where.length()>0){
                        where.replace(0, 5, "");                
                        where.insert(0, " where ");
                    }
                     super.getReportParameters().put("p_where", where.toString() );*/
                    super.getReportParameters().put("p_company", new CompanyBean().loadCompanyInfo().toString());
                    super.prepareReportViaConn();
		} catch (JRException | IOException e) {
			// make your own exception handling
		}
		
		return null;
	}
}
